#include<bits/stdc++.h>
using namespace std;
int a[101111],a1[101111],a2[101111];
int g[101111];
int b[101111];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int q=1;q<=t;q++){
        int ans1=0,ans2=0;
        memset(a,0,sizeof(a));memset(a1,0,sizeof(a1));memset(a2,0,sizeof(a2));
        memset(g,0,sizeof(g));memset(b,0,sizeof(b));
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            cin>>a[i]>>a1[i]>>a2[i];
        }
        for(int i=1;i<=m;i++)cin>>g[i];
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){

                int s=g[j]-a[i];
                if(s<0)continue;
                int v1=0;
                v1=a1[i]*a1[i]+2*s*a2[i];
                //cout<<v1<<endl;
                if(v1>v*v&&v1>=0){
                    b[i]=j;
                    ans1++;
                    break;
                }

            }
        }
        for(int i=1;i<=n;i++)g[b[i]]=-1;
        for(int i=1;i<=m;i++)
            if(g[i]!=-1)ans2++;
        if(ans1==0)ans2=m;
        cout<<ans1<<' '<<ans2<<endl;

    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
